class Solution_A {
    public int[] twoSum(int[] nums, int target) {
        int length = nums.length;
        int[] result = new int[2];
        for(int i = 0; i < length - 1; i++){
            for(int j = i + 1; j < length; j++){
                if(target == nums[i] + nums[j]){
                    result[0] = i;
                    result[1] = j;
                }
            }
        }
        return result;//数组整体传参时仅需数组名
    }
}

class Solution_B {
    public int[] twoSum(int[] nums, int target) {
        int length = nums.length;
        for(int i = 0; i < length - 1; i++){
            for(int j = i + 1; j < length; j++){
                if(nums[i] + nums[j] == target){
                    return new int[]{i, j};//将创建、赋值及传回合为一步
                }
            }
        }
        return null;//注意代码完整
    }
}